package com.java.servlet;

import com.java.bean.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: wjr
 * @Description:
 * @Date Created in  2020-09-04 0:36
 * @Modified By:
 */
@WebServlet(value = "/download")
public class DownloadServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取积分值
        int num = Integer.parseInt(req.getParameter("num"));
        if (num >= 100){
            //可以下载
            //由后台给前台返回一段js代码
            resp.setContentType("text/html;charset=utf-8");
            PrintWriter writer = resp.getWriter();
            writer.print("<script>alert('你的积分值大于100，下载成功');location.href='/comment.jsp'</script>");
        }
    }
}
